using System;
using System.Data;
using System.Data.Common;
using EPiServer.Common.Data;

namespace EPiAbstractions.Common.Data
{
    public class DatabaseHandlerFacade : IDatabaseHandlerFacade
    {
        private static DatabaseHandlerFacade _instance;

        public static DatabaseHandlerFacade Instance
        {
            get
            {
                if (_instance == null)
                    _instance = new DatabaseHandlerFacade();

                return _instance;
            }

            set { _instance = value; }
        }

        #region IDatabaseHandlerFacade Members

        public virtual DbConnection GetConnection(Boolean inTransaction)
        {
            return DatabaseHandler.GetConnection(inTransaction);
        }

        public virtual void BeginTransaction()
        {
            DatabaseHandler.BeginTransaction();
        }

        public virtual DbCommand GetCommand(Boolean inTransaction, String sp, Object[] args)
        {
            return DatabaseHandler.GetCommand(inTransaction, sp, args);
        }

        public virtual DbCommand GetCommand(Boolean inTransaction, String sp, CommandType commandType, Object[] args)
        {
            return DatabaseHandler.GetCommand(inTransaction, sp, commandType, args);
        }

        public virtual DbCommand GetCommand(String sp, Object[] args)
        {
            return DatabaseHandler.GetCommand(sp, args);
        }

        public virtual DbDataReader GetReader(Boolean inTransaction, String sp, Object[] args)
        {
            return DatabaseHandler.GetReader(inTransaction, sp, args);
        }

        public virtual DbDataReader GetReader(Boolean inTransaction, String sp, CommandType commandType, Object[] args)
        {
            return DatabaseHandler.GetReader(inTransaction, sp, commandType, args);
        }

        public virtual DbDataReader GetReader(String sp, Object[] args)
        {
            return DatabaseHandler.GetReader(sp, args);
        }

        public virtual DbDataReader GetReader(String sp, CommandType commandType, Object[] args)
        {
            return DatabaseHandler.GetReader(sp, commandType, args);
        }

        public virtual Object GetScalar(Boolean inTransaction, String sp, Object[] args)
        {
            return DatabaseHandler.GetScalar(inTransaction, sp, args);
        }

        public virtual Object GetScalar(Boolean inTransaction, String sp, CommandType commandType, Object[] args)
        {
            return DatabaseHandler.GetScalar(inTransaction, sp, commandType, args);
        }

        public virtual Object GetScalar(String sp, Object[] args)
        {
            return DatabaseHandler.GetScalar(sp, args);
        }

        public virtual Object GetScalar(String sp, CommandType commandType, Object[] args)
        {
            return DatabaseHandler.GetScalar(sp, commandType, args);
        }

        public virtual void ExecuteNonQuery(Boolean inTransaction, String sp, CommandType commandType, Object[] args)
        {
            DatabaseHandler.ExecuteNonQuery(inTransaction, sp, commandType, args);
        }

        public virtual void ExecuteNonQuery(Boolean inTransaction, String sp, Object[] args)
        {
            DatabaseHandler.ExecuteNonQuery(inTransaction, sp, args);
        }

        public virtual void ExecuteNonQuery(String sp, CommandType commandType, Object[] args)
        {
            DatabaseHandler.ExecuteNonQuery(sp, commandType, args);
        }

        public virtual void ExecuteNonQuery(String sp, Object[] args)
        {
            DatabaseHandler.ExecuteNonQuery(sp, args);
        }

        public virtual void Rollback()
        {
            DatabaseHandler.Rollback();
        }

        public virtual void Commit()
        {
            DatabaseHandler.Commit();
        }

        public virtual void FinalizeCommand(Boolean inTransaction, DbCommand command)
        {
            DatabaseHandler.FinalizeCommand(inTransaction, command);
        }

        public virtual void RunInTransaction(TransactionCode transactionCode)
        {
            DatabaseHandler.RunInTransaction(transactionCode);
        }

        #endregion
    }
}